package cn.zyzpp.config;

import cn.zyzpp.entity.user.Admin;
import cn.zyzpp.service.user.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * Create by yster@foxmail.com 2018/5/28/028 14:15
 */
@Component
public class MyApplicationRunner implements ApplicationRunner {

    @Autowired
    private AdminService adminService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Admin admin = new Admin("admin","admin");
        if (adminService.queryByName("admin")==null) {
            adminService.init(admin);
        }
    }
}
